clear, close, clc

dt = 0.001;
t = 0:dt:1;
x = sin(2*pi*50*t) + sin(2*pi*120*t);
figure(1)
plot(t,x,'LineWidth',1.2)

figure
N = length(t);
Y = fft(x,N);
PSD = Y.*conj(Y)/N;
freq = 1/(dt*N)*(0:N);
L = 1:floor(N/2);
plot(freq(L),PSD(L));
title('Power Spectrum')
xlabel('Frequency (Hz)')